//
// Created by Administrator on 2021/8/8.
//

#ifndef STRUCTVIEW_APPLYVIEW_H
#define STRUCTVIEW_APPLYVIEW_H

#include "ViewInterface.h"
#include "SimpileView.h"

namespace details {
    template<typename SegDefine>
    class SegView {
    public:
        template<typename Parent>
        auto CreateView(Parent& parent, SegDefine& view) -> ViewInterface* {
            return view(parent);
        }
    };
}

#define __def_seg_name__(seg) sEgRaW_##seg

#define VSegment(seg_name, ...) \
auto __def_seg_name__(seg_name) = __def_simple_view_without_parent(seg_name, ##__VA_ARGS__);  \
using seg_name = details::SegView<decltype(__def_seg_name__(seg_name))>

#define VApply(seg_name) __append_view__(seg_name{}.CreateView<decltype(parent)>(parent, __def_seg_name__(seg_name)))

#endif //STRUCTVIEW_APPLYVIEW_H
